package com.baishui.gateway.handler;

import com.baishui.gateway.exception.GateWayException;
import com.baishui.gateway.context.GateWayRouteContext;
import io.vertx.ext.web.RoutingContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class GlobalFailureHandler extends AbstractHandler {

    private final static Logger log = LoggerFactory.getLogger(GlobalFailureHandler.class);

    @Override
    void handle(GateWayRouteContext context, RoutingContext routingContext) throws GateWayException {
        log.error("handle error ...",routingContext.failure());
        if (routingContext.failed()) {
            writeError(routingContext);
        }
    }
}
